package com.base.controller.emr;

import com.alibaba.fastjson.JSONArray;
import com.base.api.emr.CpoeApplyService;
import com.base.vo.emr.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping(value = "/emr", produces = "application/json;charset=UTF-8")
public class CpoeApplyItemController {

    @Autowired
    private CpoeApplyService cpoeApplyService;

    @PostMapping(value = "/getApplyItemClass")

    public String getApplyItemClass() {
        return cpoeApplyService.selectAllApplyItemClass();
    }

    @PostMapping(value = "/getApplyItemDetailByClass")
    public String getApplyItemDetailByClass(CpoeApplyItemClass applyItemClass) {
        return cpoeApplyService.selectApplyItemByExecOrgCodeAndCatalogId(applyItemClass);
    }

    @PostMapping(value = "/getApplyInspByApplyId")
    public String getApplyInspByApplyId(Integer applyId) {
        return cpoeApplyService.selectApplyInsp(applyId);
    }

    @PostMapping(value = "/getApplySampleTypeByInspId")
    public String getApplySampleTypeByInspId(Integer dictInspecSampleId) {
        return cpoeApplyService.selectApplyInspSampleByInspId(dictInspecSampleId);
    }

    @PostMapping(value = "/uptApplyInspRelNew")
    public String uptApplyInspRelNew(CpoeDictApplyInspRelNew dictApplyInspRelNew) {
        return cpoeApplyService.uptApplyInspRelNew(dictApplyInspRelNew);
    }

    @PostMapping(value = "/uptApplySample")
    public String uptApplySample(CpoeBasicDictInspecSample inspecSample) {
        return cpoeApplyService.uptApplyInspSample(inspecSample);
    }

    @PostMapping(value = "/getAllSampleDetail")
    public String getAllSampleDetail() {
        return cpoeApplyService.getAllSampleDetail();
    }

    @PostMapping(value = "/addSample")
    public String addSample(String sampleArray) {
        List<CpoeBasicDictInspecSample> list = JSONArray.parseArray(sampleArray, CpoeBasicDictInspecSample.class);
        return cpoeApplyService.addSampleBatch(list);
    }

    @PostMapping(value = "/delSample")
    public String delSample(String sampleArray) {
        List<CpoeBasicDictInspecSample> list = JSONArray.parseArray(sampleArray, CpoeBasicDictInspecSample.class);
        return cpoeApplyService.delSample(list);
    }

    @PostMapping(value = "/addApplyItemInsp")
    public String addApplyItemInsp(String inspArray) {
        List<CpoeDictApplyInspRelNew> list = JSONArray.parseArray(inspArray, CpoeDictApplyInspRelNew.class);
        return cpoeApplyService.addApplyItemInsp(list);
    }

    @PostMapping(value = "/delApplyItemInsp")
    public String delApplyItemInsp(CpoeDictApplyInspRelNew dictApplyInspRelNew) {
        return cpoeApplyService.delApplyItemInsp(dictApplyInspRelNew);
    }

    @PostMapping(value = "/addApplyItem")
    public String addApplyItem(CpoeDictApplyNew cpoeDictApplyNew) {
        return cpoeApplyService.saveApplyItem(cpoeDictApplyNew);
    }

    @PostMapping(value = "/delApplyItem")
    public String delApplyItem(Integer applyId) {
        return cpoeApplyService.delApplyItem(applyId);
    }

    @PostMapping(value = "/bindApplyItem")
    public String bindApplyItem(String CpoeAppCaRelVstArray) {
        List<CpoeAppCaRelVst> list = JSONArray.parseArray(CpoeAppCaRelVstArray, CpoeAppCaRelVst.class);
        return cpoeApplyService.bindApplyItem(list);
    }

    @PostMapping(value = "/getAllApplyItemDetail")
    public String getAllApplyItemDetail() {
        return cpoeApplyService.getAllApplyItemDetail();
    }



}
